//
//  MyInfoCell.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/9/3.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "MyInfoCell.h"

@interface MyInfoCell ()

@property (nonatomic, strong) UIImageView *leftImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *rightImageView;
@property (nonatomic, strong) UIImageView *lineImageView;

@end

@implementation MyInfoCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(18, 18));
            make.left.mas_equalTo(self.contentView.mas_left).offset(23);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView);
            make.left.mas_equalTo(self.contentView.mas_left).offset(58);
        }];
        [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-12);
            make.size.mas_equalTo(CGSizeMake(18, 18));
        }];
        [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0.7f);
            make.left.mas_equalTo(self.titleLabel.mas_left);
            make.right.mas_equalTo(self.contentView.mas_right);
            make.bottom.mas_equalTo(self.contentView.mas_bottom);
        }];
    }
    return self;
}

- (void)updateDataWithModel:(UserCompleteModel *)model IndexPath:(NSIndexPath *)indexPath{
    
    self.lineImageView.hidden = NO;
    switch (indexPath.row) {
        case 0:
        {
            self.titleLabel.text = @"基本信息";
            if (model.baseInfo == 0) {
                self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
            }else{
                self.leftImageView.image = [UIImage imageNamed:@"ic_Star_selcet"];
            }
            
        }
            break;
        case 1:
        {
            self.titleLabel.text = @"现住地址";
            if (model.currentAddress == 0) {
                self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
            }else{
                self.leftImageView.image = [UIImage imageNamed:@"ic_Star_selcet"];
            }
        }
            break;
        case 2:
        {
            self.titleLabel.text = @"单位信息";
            if (model.companyInfo == 0) {
                self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
            }else{
                self.leftImageView.image = [UIImage imageNamed:@"ic_Star_selcet"];
            }
        }
            break;
        case 3:
        {
            self.titleLabel.text = @"学历信息";
            if (model.diplomasInfo == 0) {
                self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
            }else{
                self.leftImageView.image = [UIImage imageNamed:@"ic_Star_selcet"];
            }
            self.lineImageView.hidden = YES;
        }
            break;
        default:
            break;
    }
    
}

- (void)updateDataWithIndexPath:(NSIndexPath *)indexPath {
    
    self.lineImageView.hidden = NO;
    switch (indexPath.row) {
        case 0:
        {
            self.titleLabel.text = @"基本信息";
            self.leftImageView.image = [UIImage imageNamed:@"ic_Star_selcet"];
        }
            break;
        case 1:
        {
            self.titleLabel.text = @"现住地址";
            self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
        }
            break;
        case 2:
        {
            self.titleLabel.text = @"单位信息";
            self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
        }
            break;
        case 3:
        {
            self.titleLabel.text = @"学历信息";
            self.leftImageView.image = [UIImage imageNamed:@"ic_star"];
            self.lineImageView.hidden = YES;
        }
            break;
        default:
            break;
    }
}




- (UIImageView *)leftImageView {
    
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_star"]];
        [_leftImageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self.contentView addSubview:_leftImageView];
    }
    return _leftImageView;
}

- (UILabel *)titleLabel {
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.textColor = HexColor(0x333333);
        
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (UIImageView *)rightImageView {
    
    if (!_rightImageView) {
        _rightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ic_chevron_right"]];
        [_rightImageView setContentMode:UIViewContentModeScaleAspectFit];
        
        [self.contentView addSubview:_rightImageView];
    }
    return _rightImageView;
}
- (UIImageView *)lineImageView {
    
    if (!_lineImageView) {
        _lineImageView = [[UIImageView alloc] init];
        _lineImageView.backgroundColor = ThemeMaoLineColor;
        
        [self.contentView addSubview:_lineImageView];
    }
    return _lineImageView;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
